<form id="signSubmit-form" lay-filter="signSubmit-form" class="layui-form model-form">
    <input name="id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">用户ID</label>
        <div class="layui-input-block">
            <input id="userId" name="userId" class="layui-input" readonly="readonly" style="border-color: white;outline: none;border: 0">
        </div>
    </div>
    <div class="layui-form-item">
    <label class="layui-form-label">签到日期</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="time" name="time" placeholder="yyyy-MM-dd">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">签到时间</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="signin1" name="signin" placeholder="H点m分">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">签退时间</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="sigout" name="sigout" placeholder="H点m分">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">签到状态</label>
        <div class="layui-form toolbar">
            <select id="istate-search-key" name="istate">
                <option value="">-请选择-</option>
                <option value="1">已到</option>
                <option value="2">迟到</option>
                <option value="3">请假</option>
                <option value="0">未到</option>
                <option value="4">旷课</option>
            </select>&emsp;
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">签退状态</label>
        <div class="layui-form toolbar">
            <select id="ostate-search-key" name="ostate">
                <option value="">-请选择-</option>
                <option value="1">已签退</option>
                <option value="2">早退</option>
                <option value="3">请假</option>
                <option value="0">未签退</option>
                <option value="4">逃课</option>
            </select>&emsp;
        </div>
    </div>

    <div class="layui-form-item model-form-footer">
        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
        <button class="layui-btn" lay-filter="signSubmit-form-submit" lay-submit>提交</button>
    </div>
</form>

<script>
    layui.use(['form', 'table', 'util', 'config', 'index','admin','layedit'], function () {
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var layer = layui.layer;
        var util = layui.util;
        var index = layui.index;
        var admin = layui.admin;
        let userinfo = "";
        var layedit=layui.layedit;


        index.getUser(function (user) {
            userinfo=user;
        });
        //用户信息赋值
        $("#userId").val(userinfo.id);

        form.render('radio');
        //获取值
        var sign = admin.getTempData('t_sign');
        //修改赋值
        if (sign){
            $("#userId").val(sign.userId);
            $("#uname").val(sign.uname);
            $("#istate-search-key").val(sign.istate);
            $("#ostate-search-key").val(sign.ostate);
            $("#time").val(sign.time);
            $("#signin1").val(sign.signin);
            $("#sigout").val(sign.sigout);
            form.render();
        }else{
            sign={
                id:null
            }
        }

        // 表单提交事件
        form.on('submit(signSubmit-form-submit)', function (data) {
            layer.load(2);

            let res={
                id:sign.id,
                userId:data.field.userId,
                time:data.field.time,
                signin:data.field.signin,
                sigout:data.field.sigout,
                istate:data.field.istate,
                ostate:data.field.ostate
            };
            console.log(res,6549847);
            admin.req('api-sign/sign/signUpdate', JSON.stringify(res), function (data) {
                layer.closeAll('loading');
                console.log(data);
                if (data.code == 0) {
                    layer.msg(data.msg, {icon: 1, time: 500});
                    admin.finishPopupCenter();
                } else {
                    layer.msg(data.msg, {icon: 2, time: 500});
                }
            }, "POST");

            return false;
        });
    });
</script>
<script>
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#signin1'
            , type: 'time'
        });
        laydate.render({
            elem: '#sigout'
            , type: 'time'
        });
         //常规用法
        laydate.render({
            elem: '#time'
        });
    })

</script>